# -*- encoding: utf-8 -*-
# !/usr/bin/env python
'''
@File    :   Untitled-1
@Time    :   2022/04/17 14:34:03
@Author  :   Stone_Hou
@Version :   1.0
@Contact :   xiangxing985529@163.com
@License :   (C)Copyright 2010-2021, Stone_Hou
@Desc    :   None
@Refer   :   https://github.com/xiangxing98
'''

# here put the import lib
import turtle
import random

def randomcolor():
    """莫兰迪色系-高级灰色调"""
    colorArr = ["#c1cbd7", "#afb0b2", "#939391", "#bfbfbf", "#e0e5df", 
                "#b5c4b1", "#8696a7", "#9ca8b8", "#ececea", "#fffaf4",
                "#96a48b", "#7b8b6f", "#dfd7d7", "#656565", "#d8caaf",
                "#c5b8a5", "#fdf9ee", "#f0ebe5", "#d3d4cc", "#e0cdcf",
                "#b7b1a5", "#a29988", "#dadad8", "#f8ebd8", "#965454",
                "#6b5152", "#f0ebe5", "#cac3bb", "#a6a6a8", "#7a7281",
                "#a27e7e", "#ead0d1", "#faead3", "#c7b8a1", "#c9c0d3",
                "#eee5f8"]
    color = random.choice(colorArr)
    return color

def randomcolor2():
    colorArr = ['1','2','3','4','5','6','7','8','9','A','B','C','D','E','F']
    color2 = ""
    for i in range(6):
        color2 += colorArr[random.randint(0,14)]
    return "#"+color2

# turtle.speed(0)
# "fastest": 0; "fast": 10; "normal": 6; "slow": 3; "slowest": 1
# turtle.Turtle().screen.delay(0);默认情况下，绘图是有一个延迟的; 
# 可以通过这个方法把画布的延迟取消掉；

def drawShape(sides,length):
    angle = 360.0/sides
    turtle.begin_fill()
    shape_color = randomcolor()
    turtle.color(shape_color)
    turtle.speed(0)
    turtle.Turtle().screen.delay(0)
    for side in range(sides):
        turtle.forward(length)
        turtle.right(angle)
    turtle.end_fill()

def moveTurtle(x,y):
    turtle.penup()
    turtle.goto(x,y)
    turtle.pendown()

def drawSquare(length):
    drawShape(4,length)

def drawTriangle(length):
    drawShape(3,length)

def drawCircle(length):
    drawShape(360,length)

def drawRandom():
    x = random.randrange(-200,200)
    y = random.randrange(-200,200)
    length = random.randrange(75)
    shape = random.randrange(1,4)
    moveTurtle(x,y)

    if shape == 1:
        drawSquare(length)
    elif shape == 2:
        drawTriangle(length)
    elif shape == 3:
        length = length % 4
        drawCircle(length)

for shape in range(100):
    drawRandom()

turtle.done()
